conf = require("../config")
if not conf.autopairs.enabled then return {} end

return {
  'windwp/nvim-autopairs',
  event = "InsertEnter",
  -- config = true,
  config = function ()
    local npairs = require("nvim-autopairs")
    local Rule = require("nvim-autopairs.rule")
    local cond = require("nvim-autopairs.conds")
    npairs.setup({})

    -- disable pairing for some filetype
    npairs.remove_rule('`')
    npairs.add_rules({
      Rule("`", "`")
        :with_pair(cond.not_filetypes({ "verilog", "systemverilog" }))
    })
    -- npairs.get_rules("`")[1].not_filetypes = { "verilog", "systemverilog" }

    -- If you want insert `(` after select function or method item
    -- local cmp_autopairs = require('nvim-autopairs.completion.cmp')
    -- local cmp = require('cmp')
    -- cmp.event:on(
    --   'confirm_done',
    --   cmp_autopairs.on_confirm_done()
    -- )
  end,
}
